﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Windows.Forms.Design;
using mluDataEntity;

namespace mlureport
{
    public partial class Form1 : Form
    {
        bool _IsStop { get; set; }
        DataTable _dtClass { get; set; }


        public Form1()
        {
            InitializeComponent();
            
        }

        private void clientiBindingSource_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Visible = false;
        }

        private void libriDepositatiToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                mluDataEntity.Join join = new mluDataEntity.Join();
                dataGridView1.DataSource = join.ClientiDepositati();
            }
            catch (Exception er)
            {
                DialogResult res = MessageBox.Show(er.ToString(), " ", MessageBoxButtons.OKCancel);
                if (res == System.Windows.Forms.DialogResult.Cancel)
                    this.Close();
            }
        }

        private void clientiDepositatiLibriToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                mluDataEntity.Join join = new mluDataEntity.Join();
                DataTable dtJoin=join.ClientiDepositatiLibri();
                dataGridView1.DataSource = dtJoin;
            }
            catch (Exception er)
            {
                DialogResult res = MessageBox.Show(er.ToString(), " ", MessageBoxButtons.OKCancel);
                if (res == System.Windows.Forms.DialogResult.Cancel)
                    this.Close();
            }
        }

        private void clientiLibriToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                toolStripStatusLabel1.Text = "";
                toolStripStatusLabel1.Visible = true;
                toolStripStatusLabel1.Text = "Dati in caricamento";
                Cursor.Current = Cursors.WaitCursor;
                Join join = new Join();
                _dtClass = join.ClientLibri();
                dataGridView1.DataSource = _dtClass;
                Cursor.Current = Cursors.Default;
                string message = string.Format("Numero record: {0}", _dtClass.Rows.Count);
                toolStripStatusLabel1.Visible = true;
                toolStripStatusLabel1.Text = message;
            }
            catch (Exception er)
            {
                DialogResult res = MessageBox.Show(er.ToString(), " ", MessageBoxButtons.OKCancel);
                if (res == System.Windows.Forms.DialogResult.Cancel)
                    this.Close();
            }
        }

        private void portatiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                toolStripStatusLabel1.Text = "";
                toolStripStatusLabel1.Visible = true;
                toolStripStatusLabel1.Text = "Dati in caricamento";
                Cursor.Current = Cursors.WaitCursor;
                Count count = new Count();
                _dtClass = count.ClientiDepositati();
                dataGridView1.DataSource = _dtClass;
                Cursor.Current = Cursors.Default;
                string message = string.Format("Numero record: {0}", _dtClass.Rows.Count);
                toolStripStatusLabel1.Visible = true;
                toolStripStatusLabel1.Text = message;
            }
            catch (Exception er)
            {
                DialogResult res = MessageBox.Show(er.ToString(), " ", MessageBoxButtons.OKCancel);
                if (res == System.Windows.Forms.DialogResult.Cancel)
                    this.Close();
            }
        }

        private void vendutiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                toolStripStatusLabel1.Text = "";
                toolStripStatusLabel1.Visible = true;
                toolStripStatusLabel1.Text = "Dati in caricamento";
                Cursor.Current = Cursors.WaitCursor;
                Count count = new Count();
                _dtClass = count.ClientiLibriVenduti();
                dataGridView1.DataSource = _dtClass;
                Cursor.Current = Cursors.Default;
                string message = string.Format("Numero record: {0}", _dtClass.Rows.Count);
                toolStripStatusLabel1.Visible = true;
                toolStripStatusLabel1.Text = message;
            }
            catch (Exception er)
            {
                DialogResult res = MessageBox.Show(er.ToString(), " ", MessageBoxButtons.OKCancel);
                if (res == System.Windows.Forms.DialogResult.Cancel)
                    this.Close();
            }
        }

        private void depositatiVendutiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                toolStripStatusLabel1.Text = "";
                toolStripStatusLabel1.Visible = true;
                toolStripStatusLabel1.Text = "Dati in caricamento";
                Cursor.Current = Cursors.WaitCursor;
                Count count = new Count();
                _dtClass = count.ClientiDepositatiVenduti();
                dataGridView1.DataSource = _dtClass;
                Cursor.Current = Cursors.Default;
                string message = string.Format("Numero record: {0}", _dtClass.Rows.Count);
                toolStripStatusLabel1.Visible = true;
                toolStripStatusLabel1.Text = message;
            }
            catch (Exception er)
            {
                DialogResult res = MessageBox.Show(er.ToString(), " ", MessageBoxButtons.OKCancel);
                if (res == System.Windows.Forms.DialogResult.Cancel)
                    this.Close();
            }
        }


        

        
        
    }
}
